import React, {
  Component,
} from "react";
import {
  Text,
  TouchableHighlight,
  View,
  Image,
} from "react-native";
import styles from "./task-simple-sheet";
import {
  platform
} from "../../baseData";
import Navigation from '../../navigation';

export default function TaskSimple(props) {
  const router = (id, applicant_id) => {
    if (!props.router) {
      global.showToast('该任务不可查看详情');
      return;
    }
    Navigation(props.router, {
      id,
      applicant_id
    });
  }

  return (
    <TouchableHighlight underlayColor="#ebebeb" onPress={()=>{router(props.id,props.applicant_id)}} style={styles.listItem}>
      <View style={styles.content}>
        <View>
          <Text style={styles.Left}>
            {props.No}
          </Text>
        </View>

        <View style={styles.Mid}>
          <View>
            <Image resizeMode="contain" style={styles.icon} source={platform[props.platform].image} />
          </View>
          <View>
            <Text style={styles.platformName}>
              {platform[props.platform].name}
            </Text>
          </View>
        </View>

        <View style={styles.Right}>
          <Text ellipsizeMode="tail" numberOfLines={1} style={{fontSize: 18}}>
            {props.name}
          </Text>
        </View>
      </View>
    </TouchableHighlight>
  )
}